home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / WorldReady.Lib < prev   
Encoding:
Text File  |  1998-03-19  |  45.2 KB  |  1,196 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    WorldReady.Lib
  5. #
  6. #    Contains:    The library contains task specific to testing international
  7. #                (including localized) script systems.
  8. #
  9. #    Written by:    KTA
  10. #
  11. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  12. #
  13. # ****************************************************************************
  14. #            C h a n g e        H i s t o r y (most recent first):
  15. # ****************************************************************************
  16. #
  17. #        Vers      Date        Author        Description
  18. #        ----    --------    ------    ---------------------------------------------
  19. #     <1.0.9>     8/15/96    MDF        Left string number 6 in STR# ID 203 blank (which is equivalent
  20. #                                    to 'undefined').  This way when the ApplicationResourceBase
  21. #                                    variable is set to 200 (for 'US' language), CheckYesNo() in
  22. #                                    UserInterface.Lib will do the appropriate unification [button
  23. #                                    t:Don?t Save].
  24. #     <1.0.8>      5/3/96    MDF        InitINTLGlobals() - Added gSwitchToUSHook task reference to
  25. #                                    support Intl requirements when sending strings which contain
  26. #                                    precomposed doublebyte characters.
  27. #     <1.0.7>      5/1/96    MDF        Created SwitchScriptTo() and TypeKorean String() tasks. Modified
  28. #                                    INitIntleGlobals(), IntlStandardFileHooks(),
  29. #                                    StringsToSelectScript(), IsScriptInstalled(), SwitchScript(),
  30. #                                    SwitchScriptToUS(), TypeEnglishText(), HandleDoubleByteString(),
  31. #                                    TypeJapaneseString(), TypeSimplifiedChineseString(),
  32. #                                    TypeTradChineseString() and RemoveTypeStrOverRide() tasks. All
  33. #                                    changes per Intl request.
  34. #     <1.0.6>      1/8/96    ML        added BuildListFromResource
  35. #     <1.0.5>      1/2/96    ML        InitINTLGlobals - initialize dialog button globals
  36. #     <1.0.4>    11/21/95    ML        Add global gInfoString to InitINTLGlobals()
  37. #     <1.0.3>     1/19/95    KTA        Changed the name of ExceptionHandler() to ExceptionDispatcher().
  38. #     <1.0.2>     12/6/94    ML        Added Exception Handling support
  39. #     <1.0.1>     4/27/94    ML        InitINTLGlobals()-revised printlns
  40. #     <2.0.8>     3/23/94    KTA/JW    SetUpIntlGlobals() - Fixed problem when passing 
  41. #                                    in pAppLanguage that is not in pDefinedAppLanguages.
  42. #     <2.0.7>     1/18/94    KTA        Insure that SaveAs() saved the document before altering the original.
  43. #     <2.0.6>     1/12/94    KTA        Expanded TestRealDocument().
  44. #     <2.0.5>     1/12/94    KTA        Added TestRealDocument().
  45. #     <2.0.4>     1/11/94    KTA        HandleDoubleByteStrings() - Insure that the primary script is
  46. #                                    the primary script.
  47. #     <2.0.3>     1/11/94    KTA        Added UserInterFace.Lib to dependancies.
  48. #     <2.0.2>     1/11/94    KTA        Handle the typing of double byte characters more gracefully.
  49. #    <1.0.10>     12/2/93    KTA        InitINTLGlobals() nows utilizes hooks in launchTwitch so all
  50. #                                    launching will occur in English then switch back to original
  51. #                                    script.
  52. #     <1.0.9>    12/1/93        Lupe    Added the font Phayao to the Thai font list
  53. #     <1.0.8>    11/17/93    KTA        Added some changes to support performance
  54. #     <1.0.7>    11/12/93    KTA        SetUpIntlGlobals() - FontandTextLanguage wasn't being assigned properly
  55. #     <1.0.6>    11/11/93    KTA        Added task TypeEnglishText().
  56. #     <1.0.5>    11/11/93    KTA        Support a different language system for gTextStr and gFontList
  57. #     <1.0.4>     11/9/93    Lupe    In WhichScript now checks for 'U.S.' menuItem instead of 'US'
  58. #     <1.0.2>     11/4/93    KTA        Took out a couple of printlns and updated SwitchScriptUS() and
  59. #                                    SwitchScriptToOrig()
  60. #     <1.0.1>     11/04/93    KTA        Added several tasks and changed the way the globals work
  61. #     <1.0.0>     10/27/93    KTA        Created
  62. #
  63. # ****************************************************************************
  64. #
  65.  
  66. ########################################################################
  67. #                            External libraries 
  68. #=======================================================================
  69. Libraries "Output.Lib", "UserInterface.Lib", "ExceptionHandling.Lib";
  70.  
  71. #########################################################################
  72. #                    InitINTLGlobals()    
  73. #========================================================================
  74. # Author:        KTA
  75. # Description:    Redefines several global varibles based on resources that are set
  76. #                up for specific language systems.
  77. # Parameters:    None
  78. # Returns:        Nothing
  79. # Example:        InitINTLGlobals();
  80. #========================================================================
  81. # History:
  82. #    KTA        4/21/92        Created
  83. #    ML        4/27/94        revised printlns
  84. #    ML        11/16/95    add global for "info" string
  85. #    ML        1/1/96        get app resource base, define button strings
  86. #    MDF        04/30/96    Removed gLaunchTwitchHook4, and changed task refs for
  87. #                        gSetupDoText and gClearDoText to gDoTextTypeStrHook1 and
  88. #                        gDoTextTyperStrHook2, respectively, as per Intl reqs.
  89. #    MDF        05/03/96    Added gSwitchToUSHook task reference to support Intl
  90. #                        requirements when sending strings which contain 
  91. #                        precomposed doublebyte characters.
  92. #########################################################################
  93. TASK InitINTLGlobals(pAppLanguage := '', pScriptSystem := {}, pDefinedAppLanguages := {})
  94. begin
  95.     WhichLanguages := WhichLanguageResources(pAppLanguage, pScriptSystem, pDefinedAppLanguages);
  96.     
  97.     # Define the base resource for the library
  98.     ApplicationResourceBase := WhatResourceBase(WhichLanguages[1]);
  99.     LibraryResourceBase := WhatResourceBase(WhichLanguages[2]);    
  100.     FontandTextResourceBase := WhatResourceBase(WhichLanguages[3]);
  101.         
  102.         println "This is the application language - ", WhichLanguages[1];
  103.         println "This is the script system - ", WhichLanguages[2];
  104.         println "This is the font and text language - ", WhichLanguages[3];
  105.  
  106.     if (ApplicationResourceBase)
  107.     begin
  108.         global gYesString :=  GetIndString(ApplicationResourceBase+3, 1);        # "Yes", Yes/No/Cancel dialog.
  109.         global gOKString :=  GetIndString(ApplicationResourceBase+3, 2);            # "OK", OK/Cancel dialog
  110.         global gSaveString :=  GetIndString(ApplicationResourceBase+3, 3);        # "Save", Save/Don't Save/Cancel dialog.
  111.         global gCancelString :=  GetIndString(ApplicationResourceBase+3, 4);        # "Cancel", OK/Cancel dialog
  112.         global gNoString :=  GetIndString(ApplicationResourceBase+3, 5);            # "No", Yes/No/Cancel dialog.
  113.         global gDontSaveString :=  GetIndString(ApplicationResourceBase+3, 6);    # "Don't Save", Save/Don't Save/Cancel dialog.
  114.         global gQuitString :=  GetIndString(ApplicationResourceBase+3, 7);        # "Quit", Quit/Cancel dialog.
  115.  
  116.         global gRevertString :=  GetIndString(ApplicationResourceBase+3, 8);        # "Revert", menu item of File menu.
  117.     end;
  118.  
  119.     if(LibraryResourceBase)
  120.     begin
  121.  
  122.         global gScrapTitle := GetIndString(LibraryResourceBase, 2);
  123.         global gChooserTitle := GetIndString(LibraryResourceBase, 3);
  124.         global gGetInfoString := GetIndString(LibraryResourceBase, 4);
  125.         
  126.         IntlStandardFileHooks();        # Initialize the standardFileHooks
  127.  
  128.         global gLaunchTwitchHook3 := task SwitchScriptToUS;
  129.  
  130.         ###################################################################
  131.         # These library globals are for Fonts and the TextStr and can be passed in
  132.         # as the third element to pScriptSystem otherwise they will default to the 
  133.         # language of the primary Script system. 
  134.         ###################################################################
  135.         global gFontList := BuildListFromResourceINTL(FontandTextResourceBase+1);    # Base+1
  136.         global gTextStr := GetIndString(FontandTextResourceBase+2, 1);    # first element of Base+2
  137.         
  138.         ## Handle the typing of double byte characters more gracefully
  139.         ## This is only being done in DoText() since it generates its own strings based on font selections
  140.         global gDoTextTypeStrHook1 := task HandleDoubleByteStrings;
  141.         global gDoTextTypeStrHook2 := task RemoveTypeStrOverRide;
  142.         global gSwitchToUSHook := task SwitchScriptToUS;
  143.     end;
  144.     else
  145.         println "Couldn't initialize INTL globals because the pLibraryResourceBase is not defined";
  146. end; # InitINTLGlobals()
  147.  
  148. #########################################################################
  149. #    WhichLanguageResources( pAppLanguage, pScriptSystem, pDefinedAppLanguages )    
  150. #========================================================================
  151. # Author:        KTA
  152. # Description:    Sets up globals required to swap resources for different language systems. 
  153. # Parameters:    pAppLanguage := Language of the application to be tested (should be
  154. #                                language identifier see below)
  155. #                pScriptSystem := List of 2 elements
  156. #                                1st element - Language of the script system (language identifier)
  157. #                                2nd element - Boolean indicating whether script system is
  158. #                                             localized or not.
  159. #                                3rd element - Language Identifier for the language for the
  160. #                                            gFontList and gTextStr. This is an optional paramter,
  161. #                                            if it does not exist these will default to the language
  162. #                                            of the primary script system
  163. #                pDefinedAppLanguages - list of defined languages for the script
  164. # Returns:        nothing - but it sets up several globals
  165. # Example:        WhichLanguageResources('AB',{'AB',0} );
  166. # Notes:        Language Identifier
  167. #                    US - US
  168. #                    JP - Japanese
  169. #                    SC - Simplified Chinese
  170. #                    TC - Traditional Chinese
  171. #                    KH - Korean
  172. #                    AB - Arabic
  173. #                    HB - Hebrew
  174. #                    TH - Thai
  175. #                Global gLanguageSettings is defined as follows:
  176. #                    {
  177. #                    Application Language - (e.g. 'US')
  178. #                        { 
  179. #                            Primary Script Language (e.g. 'JP'), 
  180. #                            Is Primary Script Localized (i.e. 0 - NO, 1 - Yes),
  181. #                            Language for Fonts and TextStr (e.g. 'JP')
  182. #                        }
  183. #                    }
  184. #                    For example:
  185. #                        gLanguageSettings := {'US',{'JP',0,'JP'}};
  186. #========================================================================
  187. # History:
  188. #    KTA        11/1/93        Created
  189. #    KTA        11/11/93    Support passing in a differnet language identifier for
  190. #                        gFontList and gTextStr (it is the 3rd element of the script
  191. #                        parameter pScriptSystem)
  192. #    KTA        11/17/93    created global gWhichLanguages
  193. #    KTA/JW    3/23/94        Fixed problem when passing in pAppLanguage that is not
  194. #                        in pDefinedAppLanguages.
  195. #########################################################################
  196. TASK WhichLanguageResources(pAppLanguage := '', pScriptSystem := {}, pDefinedAppLanguages := {})
  197. begin
  198.     ##### Determine App Language
  199.     if (pDefinedAppLanguages)
  200.     begin    
  201.         thePrimaryScript := PrimaryScript();                    # Figure out what the Primary Script is
  202.         if not(pAppLanguage)
  203.             pAppLanguage := thePrimaryScript;                    # set the app language to the primary script
  204.         
  205.         if not(isMember(pAppLanguage,pDefinedAppLanguages))        # insure that resources have been defined for the AppLanguage requested.
  206.         begin
  207.             LogStr("Sorry, {pAppLanguage} is not contained within the list gDefinedAppLanguages");
  208.             pAppLanguage := pDefinedAppLanguages[1];            # Set it to the first element of pDefinedAppLanguages
  209.         end;
  210.         
  211.         if(pAppLanguage)                                # Set the script Resource Base            
  212.             Global gScriptResourceBase := WhatResourceBase(pAppLanguage);    
  213.     end;
  214.     else
  215.     begin
  216.         LogStr("WARNING: the list pDefinedAppLanguages has not been defined");
  217.         exit;
  218.     end;
  219.     
  220.     
  221.     ##### Determine System Language
  222.     if not (pScriptSystem)
  223.     begin
  224.         if not(pScriptSystem)                                        
  225.         begin                                                        # is the Primary Script localized
  226.             if(_matchBoolean([menuitem t:"Chooser" m:[menu o:1]]!))            # If Chooser menuItem exists then it must not be localized
  227.                 pScriptSystem := {thePrimaryScript,0};
  228.             else
  229.                 pScriptSystem := {thePrimaryScript,1};                # if file menu does not exist then it must be
  230.         end;
  231.     end;
  232.  
  233.     if(TypeOf(pScriptSystem) = 'list')
  234.     begin
  235.         isLocalized :=     pScriptSystem[2];
  236.         if (card(pScriptSystem) = 3)        # Did they specify a language for the Fonts and TextStr??
  237.             FontandTextLanguage := pScriptSystem[3];
  238.         else 
  239.             FontandTextLanguage := thePrimaryScript;            # Default is to use primary script language ID
  240.  
  241.         global gLanguageSettings := {pAppLanguage,{pScriptSystem[1],pScriptSystem[2]},FontandTextLanguage};
  242.         pScriptSystem := pScriptSystem[1];
  243.         if(isLocalized = 0)
  244.             pScriptSystem := 'US';            # Not localized
  245.     end;
  246.     else
  247.         LogStr("Sorry, the pScriptSystem has not been defined correct - it is not a list");
  248.         
  249.     return({pAppLanguage, pScriptSystem,FontandTextLanguage});
  250. end; # WhichLanguageResources()
  251.  
  252. #########################################################################
  253. #                        IntlStandardFileHooks()    
  254. #========================================================================
  255. # Author:        KTA
  256. # Description:    Set up defaults for always manipulating StandardFile in US then 
  257. #                switching back to original script 
  258. # Parameters:    None
  259. # Returns:        nothing - but it defines several global hooks
  260. # Example:        IntlStandardFileHooks();
  261. #                    
  262. #========================================================================
  263. # History:
  264. #    KTA        11/1/93        Created
  265. #    MDF        04/30/96    Removed SwitchScriptBackToOrig (for gSaveAsHook3 and
  266. #                        gOpenFileHook2) as it should always be the "U.S."
  267. #                        script, per Intl reqs.  
  268. #########################################################################
  269. task IntlStandardFileHooks()
  270. begin
  271.     global gSaveAsHook1 := task SwitchScriptToUS;
  272.     global gOpenFileHook1 := task SwitchScriptToUS;
  273. end;
  274.  
  275. #########################################################################
  276. #            MenuTitle( menuItemOrd, MenuOrd, Hmenu )    
  277. #========================================================================
  278. # Author:        KTA
  279. # Description:    Returns the title of the menuitem specified by the parameters
  280. #                in ordinality.
  281. # Parameters:    menuItemOrd - (integer) ordinality of menuItem
  282. #                MenuOrd - (integer) ordinality of menu (if its hierarchical 
  283. #                            this is the second level menu).
  284. #                Hmenu - (integer) ordinality of menu ( only defined if it
  285. #                        the menuitem is a hierarchical.  This is the top most
  286. #                        menu.
  287. # Returns:        {theMITitle,theMenuHTitle, theMenuTitle};
  288. # Example:        MenuTitle(2,3,4);
  289. #========================================================================
  290. # History:
  291. #    KTA        4/21/92        Created
  292. # ML    11/29/94    Added Exception Handling support
  293. #########################################################################
  294. TASK MenuTitle(menuItemOrd, MenuOrd, Hmenu := 0)
  295. begin
  296.     If not (hMenu)
  297.     Begin
  298.         try match[menuItem o:menuItemOrd t:?theMITitle m:[menu o:MenuOrd t:?theMenuTitle]];
  299.         catch theError
  300.             ExceptionDispatcher(theError);
  301.         print "menuItem - '", theMITitle,"'";
  302.         println " / menu - '", theMenuTitle,"'";
  303.         returnVal := {theMITitle,theMenuTitle};
  304.     end;
  305.     else
  306.     begin
  307.         try match[menuItem o:menuItemOrd t:?theMITitle  m:[menuitem o:MenuOrd t:?theMenuHTitle  m:[menu o:Hmenu t:?theMenuTitle]]];
  308.         catch theError
  309.             ExceptionDispatcher(theError);
  310.  
  311.         print "menuItem - '", theMITitle,"'";
  312.         print " / hierMenu - '", theMenuHTitle,"'";
  313.         println " / menu - '", theMenuTitle,"'";
  314.         returnVal := {theMITitle,theMenuHTitle, theMenuTitle};
  315.     end;
  316.     return(returnVal);
  317. end;
  318.  
  319. #########################################################################
  320. #            WhichScript( scriptTitle )    
  321. #========================================================================
  322. # Author:        KTA
  323. # Description:    Returns the current and primary scripts installed 
  324. # Parameters:    scriptTitle := Requested script - Will select the script <ScriptTitle>
  325. #                if it is installed
  326. # Returns:        {currentScript,primaryScript} - if successful
  327. #                0 - if failure
  328. # Example:        WhichScript('Arabic');
  329. #========================================================================
  330. # History:
  331. #    KTA        4/21/92        Created
  332. # ML    11/29/94    Added Exception Handling support
  333. #########################################################################
  334. TASK WhichScript(scriptTitle := '')
  335. begin
  336.     returnVal := 0;
  337.     #match[application t:?CurrApp];
  338.     #if not(CurrApp = 'Finder')
  339.         #Select [menuitem t:'Finder'];
  340.     if (_matchBoolean ([menuItem t:'U.S.']))
  341.     begin
  342.         try begin
  343.             match [menuItem t:'U.S.' m:[menu o:?ScriptMenu]];
  344.             match [menuItem t:?currentScript c:'' e:true m:[menu o:ScriptMenu]]!;
  345.             println "The current script is - ", currentScript;
  346.             match [menuItem t:?primaryScript o:3 e:true m:[menu o:ScriptMenu]]!;
  347.             println "The primary script is - ", primaryScript;
  348.             returnVal := {currentScript,primaryScript};
  349.             if (scriptTitle = 'All')
  350.             begin
  351.                 allScriptList := {};
  352.                 allScripts := _collect([menuItem m:[menu o:ScriptMenu]]!,1);
  353.                 for i := 3 to Card(allScripts)
  354.                 begin
  355.                     CurrentScript := allScripts[i];
  356.                     allScriptList := insert(currentScript.t, Card(allScriptList)+1,allScriptList);
  357.                     returnVal := allScriptList;
  358.                 end;
  359.             end;
  360.             else if (scriptTitle) and (scriptTitle <> currentScript)
  361.             begin
  362.                 theScript := match[menuitem t:scriptTitle m:[menu o:ScriptMenu]]!;
  363.                 if(theScript)
  364.                 begin
  365.                     if (theScript.e) 
  366.                     begin
  367.                         _select (theScript);
  368.                         Println "Selected the script - '", scriptTitle,"', it is now the current script";
  369.                         returnVal := {scriptTitle,primaryScript};
  370.                     end;
  371.                     else
  372.                         Println "!@#$% Sorry, the requested script, '", scriptTitle,"' is not enabled to select";
  373.                 end;
  374.                 else 
  375.                     Println "!@#$% There was no script - '", scriptTitle,"' to select";
  376.             end;
  377.         end; # try
  378.         catch theError
  379.             ExceptionDispatcher(theError);
  380.     end; # if (_matchBoolean ([menuItem t:'U.S.']))
  381.     else
  382.         println "There are no scripts installed";
  383.  
  384.     return(returnVal);
  385. end;
  386.  
  387.  
  388. #########################################################################
  389. #                    CurrentlySelectedScript()    
  390. #========================================================================
  391. # Author:        KTA
  392. # Description:    Returns the language identifier for the currently selected script
  393. #                system (see below for language identifiers.)
  394. # Parameters:    none
  395. # Returns:        0 - if failure
  396. #                language identifier of selected script - if successful
  397. #                    RM - Roman
  398. #                    JP - Japanese
  399. #                    SC - Simplified Chinese
  400. #                    TC - Traditional Chinese
  401. #                    KH - Korean
  402. #                    AB - Arabic
  403. #                    HB - Hebrew
  404. #                    TH - Thai
  405. # Example:        CurrentlySelectedScript();
  406. #========================================================================
  407. # History:
  408. # KTA    11/3/93        Created
  409. # ML    11/29/94    Added Exception Handling support
  410. #########################################################################
  411. TASK CurrentlySelectedScript()
  412. begin
  413.     returnVal := 0;
  414.     try match[keyboard s:?CurrentScriptCode];
  415.     catch theError
  416.         ExceptionDispatcher(theError);
  417.     if (CurrentScriptCode = 0)
  418.         returnVal := "US";            # Roman (This really shouldn't be US it should be RM)
  419.     else if (CurrentScriptCode = 1)
  420.         returnVal := "JP";            # Japanese
  421.     else if (CurrentScriptCode = 2)
  422.         returnVal := "TC";            # Traditional Chinese
  423.     else if (CurrentScriptCode = 3)
  424.         returnVal := "KH";            # Korean
  425.     else if (CurrentScriptCode = 4)
  426.         returnVal := "AB";            # Arabic
  427.     else if (CurrentScriptCode = 5)
  428.         returnVal := "HB";            # Hebrew
  429.     else if (CurrentScriptCode = 21)
  430.         returnVal := "TH";            # Thai
  431.     else if (CurrentScriptCode = 25)
  432.         returnVal := "SC";            # Simplified Chinese
  433.  
  434.     return (returnVal);
  435. end;
  436.  
  437. #########################################################################
  438. #                    PrimaryScript()    
  439. #========================================================================
  440. # Author:        KTA
  441. # Description:    Returns the language identifier for the primary script
  442. #                system (see below for language identifiers.)
  443. # Parameters:    none
  444. # Returns:        0 - if failure
  445. #                language identifier of selected script - if successful
  446. #                    RM - Roman
  447. #                    JP - Japanese
  448. #                    SC - Simplified Chinese
  449. #                    TC - Traditional Chinese
  450. #                    KH - Korean
  451. #                    AB - Arabic
  452. #                    HB - Hebrew
  453. #                    TH - Thai
  454. # Example:        PrimaryScript();
  455. #========================================================================
  456. # History:
  457. # KTA    11/3/93        Created
  458. # ML    11/29/94    Added Exception Handling support
  459. #########################################################################
  460. TASK PrimaryScript()
  461. begin
  462.     returnVal := 0;
  463.     try match[system s:?PrimaryScriptCode];
  464.     catch theError
  465.         ExceptionDispatcher(theError);
  466.     if (PrimaryScriptCode = 0)
  467.         returnVal := "US";            # Roman (This really shouldn't be US it should be RM)
  468.     else if (PrimaryScriptCode = 1)
  469.         returnVal := "JP";            # Japanese
  470.     else if (PrimaryScriptCode = 2)
  471.         returnVal := "TC";            # Traditional Chinese
  472.     else if (PrimaryScriptCode = 3)
  473.         returnVal := "KH";            # Korean
  474.     else if (PrimaryScriptCode = 4)
  475.         returnVal := "AB";            # Arabic
  476.     else if (PrimaryScriptCode = 5)
  477.         returnVal := "HB";            # Hebrew
  478.     else if (PrimaryScriptCode = 21)
  479.         returnVal := "TH";            # Thai
  480.     else if (PrimaryScriptCode = 25)
  481.         returnVal := "SC";            # Simplified Chinese
  482.  
  483.     return (returnVal);
  484. end;
  485.  
  486. #########################################################################
  487. #            WhichMenuIsKeyBoardMenu(pKeyBoardMenuString)    
  488. #========================================================================
  489. # Author:        KTA
  490. # Description:    Returns the ordinality of the KeyBoard menu. 
  491. # Parameters:    pKeyBoardMenuString := String 'About KeyBoards'
  492. #                    ( This could be different if system is localized)
  493. # Returns:        ordinality of the KeyBoard menu - if successful
  494. #                0 - if failure
  495. # Example:        WhichMenuIsKeyBoardMenu('About Keyboards…');
  496. #========================================================================
  497. # History:
  498. # KTA    11/03/93    Created
  499. # ML    11/29/94    Added Exception Handling support
  500. #########################################################################
  501. TASK WhichMenuIsKeyBoardMenu(pKeyBoardMenuString := 'About Keyboards…')
  502. begin
  503.     returnVal := 0;
  504.     if (_matchBoolean ([menuItem t:pKeyBoardMenuString]!))
  505.     begin
  506.         try match[menuItem t:pKeyBoardMenuString m:[menu o:?menuOrd]]!;
  507.         catch theError
  508.             ExceptionDispatcher(theError);
  509.         returnVal := menuOrd;
  510.     end;
  511.     else if(_matchBoolean([menuItem t:'U.S.']!))
  512.     begin
  513.         try match[menuItem t:'U.S.' m:[menu o:?menuOrd]]!;
  514.         catch theError
  515.             ExceptionDispatcher(theError);
  516.         returnVal := menuOrd;
  517.     end;
  518.     #println "This is the ReturnVal - ",returnVal;
  519.     return(returnVal);
  520. end;
  521.  
  522. #########################################################################
  523. #            StringsToSelectScript( pLanguageCode )    
  524. #========================================================================
  525. # Author:        KTA
  526. # Description:    Returns the a list which contains all of the strings for 
  527. #                the script so you can select it from the keyBoards menu.
  528. # Parameters:    pLanguageCode := Two letter language identifier (see below)
  529. #                    US - U.S.
  530. #                    JP - Japanese
  531. #                    SC - Simplified Chinese
  532. #                    TC - Traditional Chinese
  533. #                    KH - Korean
  534. #                    AB - Arabic
  535. #                    HB - Hebrew
  536. #                    TH - Thai
  537. # Returns:        0 - if failure
  538. #                List containing strings that are actually in the Keyboard menu
  539. #                for that language. - if successful#                    
  540. # Example:        StringsToSelectScript('AB');
  541. #========================================================================
  542. # History:
  543. # KTA    11/03/91    Created
  544. # MDF    04/30/96    Modified Traditional Chinese input method names, as per
  545. #                    Intl reqs.
  546. #########################################################################
  547. TASK StringsToSelectScript(pLanguageCode := '')
  548. begin
  549.     returnVal := 0;
  550.     if(pLanguageCode)
  551.     begin
  552.         if(pLanguageCode = 'US')
  553.             returnVal := {'U.S.','U.S. - System 6'};            # US
  554.         else if(pLanguageCode = 'JP')
  555.             returnVal := {'DZÇΔǶÇ˲'};                            # Japanese
  556.         else if(pLanguageCode = 'TC')
  557.             returnVal := {'¡c≈ȧ§§Â', '∫~≠µ'};                    # Traditional Chinese
  558.         else if(pLanguageCode = 'KH')
  559.             returnVal := {'«—±€ ¿‘∑¬±‚', 'Δƒøˆ ¿‘∑¬±‚'};        # Korean
  560.         else if(pLanguageCode = 'AB')
  561.             returnVal := {'Ÿ—»Í', 'Ÿ—»Í†Û«Ë—†»Ë„'};                # Arabic
  562.         else if(pLanguageCode = 'HB')
  563.             returnVal := {'Hebrew','Ú·¯È˙†ÏÓÁ˘·†È˘‡'};            # Hebrew
  564.         else if(pLanguageCode = 'TH')
  565.             returnVal := {'Thai', 'Thai-DTP', 'Thai-PattaChote'};         # Thai
  566.         else if(pLanguageCode = 'SC')
  567.             returnVal := {' ‰»Î∑Ω∑®'};                             # Simplified Chinese
  568.     end;
  569.     return(returnVal);
  570. end;
  571.  
  572. #########################################################################
  573. #            IsScriptInstalled( pTheScript )    
  574. #========================================================================
  575. # Author:        KTA
  576. # Description:    Returns a boolean which indicates whether the input parameter
  577. #                <pTheScript> is installed.
  578. # Parameters:    pTheScript - language identifier for script 
  579. #                    US - U.S.
  580. #                    JP - Japanese
  581. #                    SC - Simplified Chinese
  582. #                    TC - Traditional Chinese
  583. #                    KH - Korean
  584. #                    AB - Arabic
  585. #                    HB - Hebrew
  586. #                    TH - Thai
  587. # Returns:        1 - if script is installed
  588. #                0 - if script is not installed
  589. # Example:        IsScriptInstalled('US');
  590. #========================================================================
  591. # History:
  592. # KTA    11/03/93    Created
  593. # ML    11/29/94    Added Exception Handling support
  594. # MDF    04/30/96    Changed to check all menu items in the list, as per Intl
  595. #                    reqs.
  596. #########################################################################
  597. TASK IsScriptInstalled(pTheScript:= '')
  598. begin
  599.     returnVal := 0;            # Init returnVal
  600.     theStringList := StringsToSelectScript(pTheScript);
  601.     if(theStringList)
  602.     begin
  603.         numOfItems := card(theStringList);
  604.         for i := 1 to numOfItems        # since there is no "break" command, I can't use "for each"...
  605.         begin
  606.             KeyBoardMenuOrd := WhichMenuIsKeyBoardMenu();
  607.             if(KeyBoardMenuOrd)
  608.             begin
  609.                 if(_matchBoolean ([menuItem t:theStringList[i] m:[menu o:KeyBoardMenuOrd]]))
  610.                 begin
  611.                     returnVal := 1;
  612.                     i := numOfItems;    # break for loop.
  613.                 end;
  614.             end;
  615.             else
  616.             begin
  617.                 if(_matchBoolean ([menuItem t:theStringList[i]]))
  618.                 begin
  619.                     returnVal := 1;
  620.                     i := numOfItems;    # break for loop.
  621.                 end;
  622.             end;
  623.         end;
  624.     end;
  625.     else
  626.         returnVal := 0;
  627.     return(returnVal);
  628. end;
  629.  
  630.  
  631. #########################################################################
  632. #                        BuildListFromResourceINTL( idNum )
  633. #========================================================================
  634. # Author:        KTA 
  635. # Description:    Returns a list generated from all of the strings in a specified
  636. #                string list resource specified by <idNum>.
  637. # Parameters:    idNum := resource id number for the string list resource.
  638. # Returns:        list - all strings in specified string list resource.
  639. # Examples:        BuildListFromResource( 1000 ); 
  640. # Assumptions:    This task must be contained within the same file that contains
  641. #                the resources. Currently this task only supports up to 100 strings
  642. #                in a single str# resource.
  643. # Note:            A duplicate of this task exists in 'Globals.Lib'.  The reason
  644. #                for this is that Vu has a limitation in the way it handles 
  645. #                resources in that it requires that a full path to the file be
  646. #                provided or the resources exist in the current file.  Since we
  647. #                do not have access to a fullpath, and do not want to require
  648. #                all users to name their hard drives and folders the same, we
  649. #                opted to place a duplicate copy of this task in all files that 
  650. #                want to use it.  The naming convesion is to append the name
  651. #                of the application under test to the end of the task name.
  652. #                For example, BuildListFromResourceMacDraw()
  653. #========================================================================
  654. # History:
  655. #
  656. #########################################################################
  657. task BuildListFromResourceINTL(idNum)
  658. begin
  659.     numtimes := 100;    #Assumes no resource will contain more than 100 strings
  660.     theList := {};
  661.     for i := 1 to numtimes
  662.     begin
  663.         CurrentFont := GetIndString(idNum,i);
  664.         #Println "This is the currentFont - ", currentFont;
  665.         if (isUndefined(CurrentFont))
  666.             numtimes := i;
  667.         else
  668.             theList := Insert(CurrentFont,Card(theList)+1, theList);
  669.     end;
  670.     #println "This is theList - ", theList;
  671.     return(theList);
  672. end;
  673.  
  674.  
  675. #########################################################################
  676. #            SwitchScript( pTheScript )    
  677. #========================================================================
  678. # Author:        KTA
  679. # Description:    Selects the specified script from the KeyBoard Menu
  680. # Parameters:    pTheScript - language identifier for script 
  681. #                    US - U.S.
  682. #                    JP - Japanese
  683. #                    SC - Simplified Chinese
  684. #                    TC - Traditional Chinese
  685. #                    KH - Korean
  686. #                    AB - Arabic
  687. #                    HB - Hebrew
  688. #                    TH - Thai
  689. # Returns:        1 - if script is switched to
  690. #                0 - if script is not switched to
  691. # Example:        SwitchScript('US');
  692. #========================================================================
  693. # History:
  694. # KTA    11/03/93    Created
  695. # KTA    3/21/94        Added support for Language Kits where Keyboard menu cannot
  696. #                    be dropped when modal dialogs are present.
  697. # ML    11/29/94    Added Exception Handling support
  698. # MDF    04/30/96    Changed to check all menu items in the list, as per Intl
  699. #                    reqs.
  700. #########################################################################
  701. TASK SwitchScript(pWhichScript := '')
  702. begin
  703.     returnVal := 0;
  704.     if(IsScriptInstalled(pWhichScript))
  705.     begin
  706.         theStringList := StringsToSelectScript(pWhichScript);
  707.         numOfItems := card(theStringList);
  708.         theMenu := WhichMenuIsKeyBoardMenu();
  709.         for i := 1 to numOfItems
  710.         begin
  711.             theScript := theStringList[i];
  712.             if(theMenu)
  713.             begin
  714.                 theItem := _match([menuitem t:theScript m:[menu o:theMenu]]);
  715.                 if (theItem)
  716.                     i := numOfItems;
  717.             end;
  718.             else
  719.             begin
  720.                 try theItem := match[menuitem t:theScript m:[menu o:?theMenu]];
  721.                 catch theError
  722.                     ExceptionDispatcher(theError);
  723.                 if (theItem)
  724.                     i := numOfItems;
  725.             end;
  726.         end;
  727.  
  728.         if(theItem)
  729.         begin
  730.             if(theItem.e)
  731.             begin
  732.                 _select (theItem);
  733.                 LogStr("Selected the '{theScript}' menuItem");
  734.                 if (CurrentlySelectedScript() = pWhichScript)
  735.                     returnVal := 1;
  736.                 else
  737.                 begin
  738.                     if(pWhichScript = 'US')
  739.                     begin
  740.                         _PressKey ({CommandKey});        # Command-RightArrow will to the 'US' script system
  741.                         _Type ({RightArrowKey});
  742.                         _releaseKey ({CommandKey});
  743.                         LogStr("Typed 'Command-RightArrow' to go to the 'US' script system");
  744.                         if (CurrentlySelectedScript() = pWhichScript)
  745.                             returnVal := 1;
  746.                     end;
  747.                     else
  748.                     begin
  749.                         numtimes := 10;        # arbitrarily chose 10 as loop counter as we currently only support 8 languages
  750.                         for i := 1 to numtimes
  751.                         begin
  752.                             KeyEq(' ');        # Command-Space will move to the next script system
  753.                             if (CurrentlySelectedScript() = pWhichScript)
  754.                             begin
  755.                                 returnVal := 1;
  756.                                 i := numtimes;
  757.                             end;
  758.                         end;
  759.                     end;
  760.                 end;
  761.             end;
  762.         end;
  763.     end;
  764.     if(returnVal)
  765.         LogStr("Switched to the '{pWhichScript}' script");
  766.  
  767.     return(returnVal);
  768. end;
  769.         
  770. #########################################################################
  771. #                SwitchScriptTo(pTheScript)    
  772. #========================================================================
  773. # Author:        MF
  774. # Description:    Selects the specified script from the KeyBoard Menu
  775. # Parameters:    None 
  776. # Returns:        what SwitchScript returns
  777. # Example:        SwitchScriptTo('JP');
  778. #========================================================================
  779. # History:
  780. # MDF    04/30/96    Created.  This is a more general purpose task than 
  781. #                    SwitchScriptToUS(), as per Intl request.
  782. #########################################################################
  783. task SwitchScriptTo(pTheScript := 'US')
  784. begin
  785.     global gtheCurrentScript := CurrentlySelectedScript();
  786.     if not(gtheCurrentScript = pTheScript)
  787.         return(SwitchScript(pTheScript));
  788. end;
  789.  
  790. #########################################################################
  791. #                SwitchScriptToUS()    
  792. #========================================================================
  793. # Author:        KTA
  794. # Description:    Selects the US script from the KeyBoard Menu
  795. # Parameters:    None 
  796. # Returns:        what SwitchScript returns
  797. # Example:        SwitchScriptToUS();
  798. #========================================================================
  799. # History:
  800. # KTA    11/03/93    Created
  801. # MDF    04/30/96    Now checks gtheCurrentScript in the conditional, instead
  802. #                    of calling CurrentlySelectScript().
  803. #########################################################################
  804. task SwitchScriptToUS()
  805. begin
  806.     global gtheCurrentScript := CurrentlySelectedScript();
  807.     if not(gtheCurrentScript = 'US')
  808.         return(SwitchScript('US'));
  809. end;
  810.  
  811. #########################################################################
  812. #                SwitchScriptBackToOrig()    
  813. #========================================================================
  814. # Author:        KTA
  815. # Description:    Selects the script specified by the global <gtheCurrentScript>
  816. #                from the KeyBoard Menu
  817. # Parameters:    None 
  818. # Returns:        what SwitchScript returns
  819. # Example:        SwitchScriptBackToOrig();
  820. #========================================================================
  821. # History:
  822. # KTA    11/03/93    Created
  823. #########################################################################
  824. task SwitchScriptBackToOrig()
  825. begin
  826.     returnVal := 0;
  827.     if(global gtheCurrentScript)
  828.     begin
  829.         if not (CurrentlySelectedScript() = gtheCurrentScript)
  830.             returnVal := SwitchScript(gtheCurrentScript);
  831.         gtheCurrentScript := 0;
  832.     end;
  833.     return(returnVal);
  834. end;
  835.  
  836. #########################################################################
  837. #            WhatResourceBase(pLanguageIdentifier)    
  838. #========================================================================
  839. # Author:        KTA
  840. # Description:    Returns a Resource base number for a given language identifier 
  841. # Parameters:    pLanguageIdentifier := 
  842. #                    US - US
  843. #                    JP - Japanese
  844. #                    SC - Simplified Chinese
  845. #                    TC - Traditional Chinese
  846. #                    KH - Korean
  847. #                    AB - Arabic
  848. #                    HB - Hebrew
  849. #                    TH - Thai
  850. #
  851. # Returns:        Integer which is the base resource for that particular language
  852. # Example:        mybaseRes := WhatResourceBase('AB');
  853. #                    
  854. #========================================================================
  855. # History:
  856. #    KTA        11/10/93        Created
  857. #########################################################################
  858. TASK WhatResourceBase(pLanguageIdentifier := '')
  859. begin
  860.      if(pLanguageIdentifier = 'US')                    # US - 200-299
  861.         returnVal := 200;    
  862.     else if(pLanguageIdentifier = 'JP')                # Japanese - 300-399
  863.         returnVal := 300;        
  864.     else if(pLanguageIdentifier = 'SC')                # Simplified Chinese - 400-499
  865.         returnVal := 400;        
  866.     else if(pLanguageIdentifier = 'TC')                # Traditional Chinese - 500-599
  867.         returnVal := 500;        
  868.     else if(pLanguageIdentifier = 'KH')                # Korean - 600-699
  869.         returnVal := 600;        
  870.     else if(pLanguageIdentifier = 'AB')                # Arabic - 700-799
  871.         returnVal := 700;        
  872.     else if(pLanguageIdentifier = 'HB')                # Hebrew - 800-899
  873.         returnVal := 800;        
  874.     else if(pLanguageIdentifier = 'TH')                # Thai - 900-999
  875.         returnVal := 900;        
  876.  
  877.     return(returnVal);
  878. end;
  879.  
  880.  
  881. #########################################################################
  882. #                    TypeEnglishText()    
  883. #========================================================================
  884. # Author:        KTA
  885. # Description:    Switches to the U.S. script system, type a line of english text 
  886. #                and switches back to the original script.
  887. # Parameters:    none
  888. # Returns:        nothing
  889. # Example:        TypeEnglishText();
  890. #                    
  891. #========================================================================
  892. # History:
  893. # KTA    11/11/93    Created
  894. # ML    11/29/94    Added Exception Handling support
  895. # MDF    04/30/96    Removed SwitchScriptBackToOrig() as there is not need to
  896. #                    switch back to the original script.
  897. #########################################################################
  898. TASK TypeEnglishText()
  899. begin
  900.     SwitchScriptToUS();
  901.     USBaseResource := WhatResourceBase('US');
  902.     theTextStr := GetIndString(USBaseResource+2,1);    # Get english text
  903.     
  904.     _type ({theTextStr});
  905.     println "Typed '{theTextStr}'";
  906. end;
  907.  
  908. #########################################################################
  909. #                    GenerateStandardFontRecord()    
  910. #========================================================================
  911. # Author:        KTA
  912. # Description:    Generates a font record based on the first element of gFontList,
  913. #                the first element of gFontSizeList and the first two elements of 
  914. #                gFontStyleList.
  915. # Parameters:    none
  916. # Returns:        theFontRecord - the font record that is generated
  917. # Example:        myfontRecord := GenerateStandardFontRecord();
  918. #                    
  919. #========================================================================
  920. # History:
  921. #    KTA        11/11/93        Created
  922. #########################################################################
  923. Task GenerateStandardFontRecord()
  924. begin
  925.     global gFontStyleList, gFontSizeList, gFontList;    
  926.     theFontRecord := {gFontList[1],gFontSizeList[1],{gFontStyleList[1], gFontStyleList[2]}};
  927.     return(theFontRecord);
  928. end;
  929.  
  930.  
  931. #########################################################################
  932. #                    HandleDoubleByteStrings(pTestMethod, pNumTimes)    
  933. #========================================================================
  934. # Author:        KTA
  935. # Description:    Defines an override task for typeStr if the current script system
  936. #                uses double byte characters.  The side effect of this task is
  937. #                that the global gTypeStrOverRide will be defined and all calls to TypeStr()
  938. #                will be redirected to call the task that has been defined for a specific 
  939. #                script system. To remove the effects of this call it is possible to '
  940. #                redefine gTypeStrOverRide as follows:
  941. #                    global gTypeStrOverRide := 0;
  942. # Parameters:    none
  943. # Returns:        currScript - language identifier of the currently selected script
  944. # Example:        HandleDoubleByteStrings();
  945. #========================================================================
  946. # History:
  947. #    KTA        1/11/94        Created
  948. #    KTA        1/11/94        Insure that the primary script is the primary script
  949. #    MDF        04/30/96    Added Korean string support, and changed to override
  950. #                        if fontAndTextLanguage is not 'US', as per Intl reqs.
  951. #########################################################################
  952. TASK HandleDoubleByteStrings(pTestMethod, pNumTimes)
  953. begin
  954.     global gLanguageSettings;
  955.  
  956.     currScript := CurrentlySelectedScript();
  957.     fontAndTextLanguage := gLanguageSettings[3];
  958.  
  959.     # Insure that the current script is the fontAndTextLanguage script
  960.     if(currScript <> fontAndTextLanguage)
  961.     begin
  962.         SwitchScript(fontAndTextLanguage);
  963.         currScript := CurrentlySelectedScript();    # Get the real current script to make sure
  964.     end;
  965.     
  966.     if(currScript = 'JP')
  967.         global gTypeStrOverRide := task TypeJapaneseString;
  968.     if(currScript = 'KH')
  969.         global gTypeStrOverRide := task TypeKoreanString;
  970.     if(currScript = 'SC')
  971.         global gTypeStrOverRide := task TypeSimplifiedChineseString;
  972.     if(currScript = 'TC')
  973.         global gTypeStrOverRide := task TypeTradChineseString;
  974.     return(currScript);
  975. end;
  976.  
  977. #########################################################################
  978. #                    TypeJapaneseString()    
  979. #========================================================================
  980. # Author:        KTA
  981. # Description:    Types a predefined string that will generate a Japanese string when
  982. #                typed into the bottom line input window. 
  983. # Parameters:    pdumpedStr - When overriding TypeStr() the string that was
  984. #                            to be typed is passed to the Overriding task.  It 
  985. #                            is ignored in this task.
  986. #                pJapaneseString - a string of characters that will produce a Japanese 
  987. #                             string when typed into the bottom line input window.
  988. # Returns:        nothing
  989. # Example:        TypeJapaneseString();
  990. #========================================================================
  991. # History:
  992. # KTA    1/11/94        Created
  993. # ML    11/29/94    Added Exception Handling support
  994. # MDF    04/30/96    Changed input method for Hiragana and added appropriate
  995. #                    script switching, as per Intl request.
  996. #########################################################################
  997. TASK TypeJapaneseString(pdumpedStr := '', pJapaneseString := 'jikangaarebategamiwokudasarebaiitoomoimasu. ')
  998. begin
  999.     SwitchScriptTo('JP');
  1000.  
  1001.     ##Press Option+Shift+Z to set input method to Hiragana
  1002.     _presskey ({OptionKey, Shiftkey});
  1003.     _type ({'z'});
  1004.     _releaseKey ({OptionKey, Shiftkey});
  1005.     
  1006.     _type ({pJapaneseString, returnkey});
  1007.     LogStr("Typed '{pJapaneseString}' and the return key");
  1008.  
  1009.     SwitchScriptTo('US');
  1010. end;
  1011.  
  1012. #########################################################################
  1013. #                    TypeKoreanString()    
  1014. #========================================================================
  1015. # Author:        KTA
  1016. # Description:    Types a predefined string that will generate a Korean string when
  1017. #                typed into the bottom line input window. 
  1018. # Parameters:    pdumpedStr - When overriding TypeStr() the string that was
  1019. #                            to be typed is passed to the Overriding task.  It 
  1020. #                            is ignored in this task.
  1021. #                TypeKoreanString - a string of characters that will produce a Korean 
  1022. #                             string when typed into the bottom line input window.
  1023. # Returns:        nothing
  1024. # Example:        TypeKoreanString();
  1025. #========================================================================
  1026. # History:
  1027. # MDF    04/30/96    Added task as per Intl request.
  1028. #########################################################################
  1029. TASK TypeKoreanString(pdumpedStr := '', pKoreanString := 'gksksladms ekdtlsdmf tkfkdgktlqslek.')
  1030. begin
  1031.     SwitchScriptTo('KH');
  1032.  
  1033.     _type ({pKoreanString, returnkey});        # hit return, just in case of there is a floating input window.
  1034.     LogStr("Typed '{pKoreanString}' and the return key");
  1035.  
  1036.     SwitchScriptTo('US');
  1037. end;
  1038.  
  1039. #########################################################################
  1040. #                    TypeSimplifiedChineseString()    
  1041. #========================================================================
  1042. # Author:        KTA
  1043. # Description:    First option-shift-'c' will be typed to set the input method to
  1044. #                Pinyin.  Then, types a predefined string that will generate a
  1045. #                SChinese string when typed into the bottom line input window.
  1046. # Parameters:    pdumpedStr - When overriding TypeStr() the string that was
  1047. #                            to be typed is passed to the Overriding task.  It 
  1048. #                            is ignored in this task.
  1049. #                pSChineseString - a string of characters that will produce a
  1050. #                                  SChinese string when typed into the bottom
  1051. #                                  line input window.
  1052. # Returns:        nothing
  1053. # Example:        TypeSimplifiedChineseString();
  1054. #========================================================================
  1055. # History:
  1056. #    KTA        1/11/94        Created
  1057. # ML    11/29/94    Added Exception Handling support
  1058. # MDF    04/30/96    Added appropriate script switch and changed the sample
  1059. #                    key strokes.
  1060. #########################################################################
  1061. TASK TypeSimplifiedChineseString(pdumpedStr := '', pSChineseString := {'pin9', 'guo4', 'dian9', 'nao2', 'gong8', 'si8'})
  1062. begin
  1063.     SwitchScriptTo('SC');
  1064.  
  1065.     ##Press Option+Shift+C to set input method to Pinyin
  1066.     _presskey ({OptionKey, Shiftkey});
  1067.     _type ({'c'});
  1068.     _releaseKey ({OptionKey, Shiftkey});
  1069.     
  1070.     for each chineseChar in pSChineseString
  1071.     begin
  1072.         _type ({chineseChar});
  1073.         LogStr("Typed '{chineseChar}'");
  1074.     end;
  1075.     _type ({returnkey});        # hit return, just in case of there is a floating input window.
  1076.     LogStr("Typed the return key");
  1077.  
  1078.     SwitchScriptTo('US');
  1079. end;
  1080.  
  1081. #########################################################################
  1082. #                    TypeTradChineseString()    
  1083. #========================================================================
  1084. # Author:        KTA
  1085. # Description:    First the menuitem for Traditional Chises will be selected.
  1086. #                Then, option-shift-'c' will be typed to set the input method to Pinyin
  1087. #                Finally, Types a predefined string that will generate a TChinese string when
  1088. #                typed into the bottom line input window.
  1089. # Parameters:    pdumpedStr - When overriding TypeStr() the string that was
  1090. #                            to be typed is passed to the Overriding task.  It 
  1091. #                            is ignored in this task.
  1092. #                pTradChineseSting - a string of characters that will produce a TChinese 
  1093. #                             string when typed into the bottom line input window.
  1094. # Returns:        nothing
  1095. # Example:        TypeTradChineseString();
  1096. #========================================================================
  1097. # History:
  1098. # KTA    1/11/94        Created
  1099. # ML    11/29/94    Added Exception Handling support
  1100. # MDF    04/30/96    Added appropriate script switch, added return key at end
  1101. #                    of the string, and removed SelectMenuItem('¡c≈ȧ§§Â') since
  1102. #                    input method name was modified in StringsToSelectScript(),
  1103. #                    as per Intl request.
  1104. #########################################################################
  1105. TASK TypeTradChineseString(pdumpedStr := '', pTradChineseSting := {'wo 1','men 1','shi 1','zhong 1','guo 1','ren 1','ta 1','men 1','shi 1','ben 1','di 1','ren 1'})
  1106. begin
  1107.     SwitchScriptTo('TC');
  1108.  
  1109.     ##Press Option+Shift+C to set input method to Pinyin
  1110.     _presskey ({OptionKey, Shiftkey});
  1111.     _type ({'c'});
  1112.     _releaseKey ({OptionKey, Shiftkey});
  1113.     
  1114.     for each chineseChar in pTradChineseSting
  1115.     begin
  1116.         _type ({chineseChar});
  1117.         LogStr("Typed {chineseChar}");
  1118.     end;
  1119.     _type ({returnkey});        # hit return, just in case of there is a floating input window.
  1120.     LogStr("Typed the return key");
  1121.  
  1122.     SwitchScriptTo('US');
  1123. end;
  1124.  
  1125.  
  1126. #########################################################################
  1127. #                    RemoveTypeStrOverRide(pTestMethod, pNumTimes)    
  1128. #========================================================================
  1129. # Author:        KTA
  1130. # Description:    Removes whatever task reference that has been defined for
  1131. #                gTypeStrOverRide.
  1132. # Parameters:    none
  1133. # Returns:        nothing
  1134. # Example:        RemoveTypeStrOverRide();
  1135. #========================================================================
  1136. # History:
  1137. # KTA    1/11/94        Created
  1138. # MDF    04/24/96    Added parameters to the task to support calls from task
  1139. #                    reference, i.e., call(gClearDoText, pTestMethod, pNumTimes).
  1140. #########################################################################
  1141. TASK RemoveTypeStrOverRide(pTestMethod, pNumTimes)
  1142. begin
  1143.     global gTypeStrOverRide := 0;
  1144. end; # RemoveTypeStrOverRide
  1145.  
  1146. #########################################################################
  1147. #                BuildListFromResource(idNum, pFileName := "")
  1148. #========================================================================
  1149. # Author:        KTA 
  1150. # Description:    Returns a list generated from all of the strings in a specified
  1151. #                string list resource specified by <idNum> from the file specified
  1152. #                by pFileName.
  1153. # Parameters:    idNum := resource id number for the string list resource.
  1154. #                pFileName - full path name of file where string resource is located.
  1155. # Returns:        list - all strings in specified string list resource.
  1156. # Examples:        BuildListFromResource( 1000, FileOfTask() ); 
  1157. # Note:            If string resource is located in script which you're calling
  1158. #                this task from, use FileOfTask() to pass in full path
  1159. #                filename as per the above example.
  1160. #========================================================================
  1161. # History:
  1162. #
  1163. #########################################################################
  1164. task BuildListFromResource(idNum, pFileName := "")
  1165. begin
  1166.     theList := {};
  1167.     CurrentItem := 0;    # Init
  1168.     i := 0;
  1169.     
  1170.     # To handle lists as returned by FileOfTask()
  1171.     if(typeof(pFileName) = 'list')    
  1172.         pFileName := pFileName[1]+pFileName[2];
  1173.     
  1174.     if(pFileName)
  1175.     begin
  1176.         while not(IsUndefined(CurrentItem))
  1177.         begin        
  1178.             i := i +1;
  1179.             CurrentItem := GetIndString(idNum,i, pFileName);
  1180.             if(CurrentItem)
  1181.                 theList[Card(theList)+1] := CurrentItem;
  1182.         end;
  1183.     end;
  1184.     else
  1185.     begin
  1186.         while not(IsUndefined(CurrentItem))
  1187.         begin        
  1188.             i := i +1;
  1189.             CurrentItem := GetIndString(idNum,i);
  1190.             if(CurrentItem)
  1191.                 theList[Card(theList)+1] := CurrentItem;
  1192.         end;
  1193.     end;
  1194.     return(theList);
  1195. end;
  1196.